/*
* 回复信息模板
* */

module.exports = options =>{
    let reqlyMessage =`<xml>
                           <ToUserName><![CDATA[${options.toUserName}]]></ToUserName>
                           <FromUserName><![CDATA[${options.fromUserName}]]></FromUserName>
                           <CreateTime>${options.createTime}</CreateTime>
                           <MsgType><![CDATA[${options.msgType}]]></MsgType>`;
    if(options.msgType === 'text'){//回复文本消息
        reqlyMessage +=`<Content><![CDATA[${options.content}]]></Content>`;
    }else if(options.msgType === 'image'){//回复图片消息
        reqlyMessage +=`<Image><MediaId><![CDATA[${options.mediaId}]]></MediaId></Image>`;
    }else if(options.msgType === 'voice'){//回复语音消息
        reqlyMessage +=`<Voice><MediaId><![CDATA[${options.mediaId}]]></MediaId></Voice>`;
    }else if(options.msgType === 'video'){//回复视频消息
        reqlyMessage +=`<Video>
                          <MediaId><![CDATA[${options.mediaId}]]></MediaId>
                          <Title><![CDATA[${options.title}]]></Title>
                          <Description><![CDATA[${options.description}]]></Description>
                        </Video>`;
    }else if(options.msgType === 'music'){//回复音乐消息
        reqlyMessage +=`<Music>
                          <Title><![CDATA[${options.title}]]></Title>
                          <Description><![CDATA[${options.description}]]></Description>
                          <MusicUrl><![CDATA[${options.musicUrl}]]></MusicUrl>
                          <HQMusicUrl><![CDATA[${options.hqMusicUrl}]]></HQMusicUrl>
                          <ThumbMediaId><![CDATA[${options.mediaId}]]></ThumbMediaId>
                        </Music>`;
    }else if(options.msgType === 'news'){//回复图文消息
        reqlyMessage +=`<ArticleCount>${options.content.length}</ArticleCount>
                        <Articles>`
        //图文消息有多条数据
        options.content.forEach(item=>{
            reqlyMessage += `<item>
                            <Title><![CDATA[${item.title1}]]></Title>
                            <Description><![CDATA[${item.description1}]]></Description>
                            <PicUrl><![CDATA[${item.picUrl}]]></PicUrl>
                            <Url><![CDATA[${item.url}]]></Url>
                          </item>`
        })
        reqlyMessage +=`</Articles>`;
    }

    reqlyMessage += `</xml>`
    //最终返回给用户的 xml 数据
    return reqlyMessage;
}